using ns0;
using ns2;
using ns4;
using System;
namespace ns10
{
	public sealed class Decoder
	{
		private ReedSolomonDecoder reedSolomonDecoder_0;
		public Decoder()
		{
			this.reedSolomonDecoder_0 = new ReedSolomonDecoder(GF256.QR_CODE_FIELD);
		}
		public DecoderResult decode(bool[][] image)
		{
			int num = image.Length;
			BitMatrix bitMatrix = new BitMatrix(num);
			for (int i = 0; i < num; i++)
			{
				for (int j = 0; j < num; j++)
				{
					if (image[i][j])
					{
						bitMatrix.set_Renamed(j, i);
					}
				}
			}
			return this.decode(bitMatrix);
		}
		public DecoderResult decode(BitMatrix bits)
		{
			Class22 @class = new Class22(bits);
			Version version_ = @class.method_1();
			ErrorCorrectionLevel errorCorrectionLevel_ = @class.method_0().method_0();
			sbyte[] sbyte_ = @class.method_3();
			Class23[] array = Class23.smethod_0(sbyte_, version_, errorCorrectionLevel_);
			int num = 0;
			for (int i = 0; i < array.Length; i++)
			{
				num += array[i].method_0();
			}
			sbyte[] array2 = new sbyte[num];
			int num2 = 0;
			for (int j = 0; j < array.Length; j++)
			{
				Class23 class2 = array[j];
				sbyte[] array3 = class2.method_1();
				int num3 = class2.method_0();
				this.method_0(array3, num3);
				for (int i = 0; i < num3; i++)
				{
					array2[num2++] = array3[i];
				}
			}
			return Class12.smethod_0(array2, version_, errorCorrectionLevel_);
		}
		private void method_0(sbyte[] sbyte_0, int int_0)
		{
			int num = sbyte_0.Length;
			int[] array = new int[num];
			for (int i = 0; i < num; i++)
			{
				array[i] = ((int)sbyte_0[i] & 255);
			}
			int twoS = sbyte_0.Length - int_0;
			try
			{
				this.reedSolomonDecoder_0.decode(array, twoS);
			}
			catch (ReedSolomonException)
			{
				throw ReaderException.Instance;
			}
			for (int i = 0; i < int_0; i++)
			{
				sbyte_0[i] = (sbyte)array[i];
			}
		}
	}
}
